package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要查找书的名字：");
        String name = scanner.nextLine();
        Book[] book = bookList.getBooks();
        int bookSize = bookList.getBookSize();
        for (int i = 0; i < bookSize; i++) {
            if(book[i].getName().equals(name)) {
                System.out.println("找到了！");
                System.out.println(book[i]);
                return;
            }
        }
        System.out.println("该书不存在！");
    }
}
